<?php

class Config{
	
	protected $_config = null;
	protected $_key;
	public function __construct($config = null){
		if(is_array($config)){
			$this->setConfig($config);
		}else{
			$configFile = is_string($config)?$config:CONFIGPATH."config.php";
			if(file_exists($configFile)){
				include $configFile;				
				if(isset($config)){
					$this->setConfig($config);
				}
			}else{
				echo 'no config file';
			}
		}		
	}
	public function setConfig($config){
		$this->_config = $config;
	}
	
	public function getKey($key){		
		$configObj =  new Config(array());
		if(isset($this->_config[$key]))
			$configObj->setConfig($this->_config[$key]);
		else
			$configObj->setConfig(null);
		return $configObj;
	}
	public function get(){
		return $this->_config;
	}
	
}